import { deepclone } from "@/utils"
import { Widget } from "../widget"
import { containerFields } from "../widget-panel/widgetsConfig"
export class AddColToGridCommand {
  constructor(cols, widgetMap) {
    const gridCol = containerFields.filter((item) => item.type === 'grid-col')[0]
    this.gridCol = new Widget(deepclone(gridCol))
    this.cols = cols
    this.widgetMap = widgetMap
  }
  execute() {
    this.cols.push(this.gridCol)
    this.widgetMap.set(this.gridCol.options.propName, this.gridCol)
  }
  undo() {
    this.cols.pop()
    this.widgetMap.delete(this.gridCol.options.propName)
  }
}